1. How many people are in the classroom with you now?
  (n <- 16)
## [1] 16
  1. How many of them can roll their tongue?
  (x <- 14)
## [1] 14
  1. What is the proportion of students who can roll their tongue, using the people in the classroom as the sample? Use correct notation with your answer.
  (p_hat <- x/n)
## [1] 0.875
  1. What quantity are we estimating if we use this information to construct a confidence interval? Use correct notation and define the parameter. What is a reasonable population?

\(p\) is the population proportion of individuals who can roll their tongue. A reasonable population would be…

  1. Use the information to construct a 95% confidence interval for the parameter defined in #4. Interpret the result.
  (z_star <- qnorm(c(0.025,0.975),0,1))
## [1] -1.959964  1.959964
  (se <- sqrt(p_hat*(1-p_hat)/n))
## [1] 0.08267973
  p_hat + z_star*se
## [1] 0.7129507 1.0370493

Was \(n\) large?

  n*p_hat >= 10 & n*(1-p_hat) >= 10
## [1] FALSE

It looks like we have a problem. Maybe the bootstrap is a better approach.

  ### Bootstrap of the proportion of the data from above. 
  ### Make sure that the boot package is installed using
  ### install.packages("boot"), or use a package like pacman to take care
  ### of installation and loading.
  #library(boot)
  p_load(boot)

  ### Make the observed data
  obs <- c(rep(1,x),rep(0,n-x))
  obs
##  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0
  ### Define the proportion function with data, d, and boot sample indices, i.
  mystat <- function(d, i){
                           sum(d[i])/length(d[i])
                          }
  
  ### Use the boot function to run the bootstrap
  boots <- boot(obs, mystat, R=9999)
  boots
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = obs, statistic = mystat, R = 9999)
## 
## 
## Bootstrap Statistics :
##     original      bias    std. error
## t1*    0.875 0.001037604   0.0815443
  plot(boots)

  ### Get 95% CI
  boot.ci(boots, 0.95, type=c("norm","perc"))
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 9999 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = boots, conf = 0.95, type = c("norm", "perc"))
## 
## Intervals : 
## Level      Normal             Percentile     
## 95%   ( 0.7141,  1.0338 )   ( 0.6875,  1.0000 )  
## Calculations and Intervals on Original Scale
  1. Tongue rolling has been said to be a dominant trait, in which case theoretically 75% of all people should be able to roll their tongues. Do our data provide evidence otherwise?

\(H_0: p = 0.75\) vs. \(H_A: p \ne 0.75\)

Is n “large”?

  n*p_hat >= 10 & n*(1-p_hat) >= 10
## [1] FALSE

We will ignore this for now and proceed with the normal test.

  (p0 <- 0.75)
## [1] 0.75
  (alpha <- c(0.1, 0.05, 0.01))
## [1] 0.10 0.05 0.01
  (z <- (p_hat - p0)/sqrt(p0*(1-p0)/n))
## [1] 1.154701
  (p_value <- 2*pnorm(-abs(z)))
## [1] 0.2482131
  reject_H0 <- (p_value <= alpha)
  cbind(alpha, reject_H0)
##      alpha reject_H0
## [1,]  0.10         0
## [2,]  0.05         0
## [3,]  0.01         0

Note that \(p = 0.75\) is in the bootstrap confidence interval ( 0.6875, 1 ) that we found above, so we would not reject the plausible value.